Page({
  data: {
    current: 'tab1',
    current_scroll: 'tab1',
    tab1:true,
    enableCamera:true,
    cameraContext: {}
  },

  handleChange({ detail }) {
    var index = detail.key
    console.log(index)
    this.setData({
      current: detail.key
    });
    if (index == 'tab1') {
      this.setData({
        tab1: true,
        tab2: false
      })
    } else if (index == 'tab2') {
      this.setData({
        tab1: false,
        tab2: true
      })
    }
    // this.setData({
    //   current: detail.key
    // });
  },
  onShow:function(){
    this.createContext();
    wx.setKeepScreenOn({
      keepScreenOn: true,
    });
    wx.getSetting({
      success(res) {
        console.log(res.authSetting)
        // res.authSetting = {
        //   "scope.userInfo": true,
        //   "scope.userLocation": true
        // }
      }
    })
  },
  createContext: function () {
    this.setData({
      cameraContext: wx.createLivePusherContext('camera-push'),
    })
  },
  handleChangeScroll({ detail }) {
    this.setData({
      current_scroll: detail.key
    });
  },
  statechange(e) {
    console.log('live-player code:', e.detail.code)
  },
  error(e) {
    console.error('live-player error:', e.detail.errMsg)
  }
})